package com.tanxiaoyao.wecon.app;

/**
 * 应用程序启动类，展示动画并跳转到主界面
 * @author tanxiaoyao (junlidev@gmail.com)
 * @created 2014-08-28
 */

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import com.tanxiaoyao.wecon.R;
import com.tanxiaoyao.wecon.ui.ActivityMain;

public class AppStart extends Activity {
    /**
     * Called when the activity is first created.
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        实例化flash
        final View flashView = View.inflate(this, R.layout.activity_app_start, null);
        setContentView(flashView);
//		渐变动画展示启动图
        AlphaAnimation flashAlphaAnimation = new AlphaAnimation(0.3f, 1.0f);
        flashAlphaAnimation.setDuration(2000);
        flashView.startAnimation(flashAlphaAnimation);
//		注册动画完成事件监听器
        flashAlphaAnimation.setAnimationListener(new Animation.AnimationListener() {

            @Override
            public void onAnimationStart(Animation animation) {

            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {
//				动画完成后跳转
                redirectTo();

            }
        });
    }

    /**
     * 界面跳转方法
     */
    private void redirectTo() {
        Intent _intent = new Intent(this, ActivityMain.class);
        startActivity(_intent);
        finish();
    }
}
